package com.bigdata.model;

public class AjaxResult<T> {

    public static int CODE_OK = 200;
    public static int CODE_ERROR = 501;
    public static int CODE_NOTLOGIN = 101;
    public static int CODE_LOGINTIMEOUT = 102;
    public static int CODE_REDLOAD = 103;
    public static int CODE_UNKNOWN = 301;

    private int code = CODE_OK;
    private String message;

    private Object data;

    public static AjaxResult ok() {
        AjaxResult ajax = new AjaxResult();
        ajax.setCode(AjaxResult.CODE_OK);
        return ajax;
    }

    public static AjaxResult ok(Object obj) {
        AjaxResult ajax = new AjaxResult();
        ajax.setCode(AjaxResult.CODE_OK);
        ajax.setData(obj);
        return ajax;
    }

    public static AjaxResult fail() {
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setCode(AjaxResult.CODE_ERROR);
        return ajaxResult;
    }

    public static AjaxResult fail(String message) {
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setCode(AjaxResult.CODE_ERROR);
        ajaxResult.setMessage(message);
        return ajaxResult;
    }

    public static AjaxResult authc(String message) {
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setCode(AjaxResult.CODE_NOTLOGIN);
        ajaxResult.setMessage(message);
        return ajaxResult;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }


    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

}
